<!-- 添加字典数据 -->
<template>
  <div>
    <el-dialog
      title="添加字典数据"
      :visible.sync="isShowDialog"
      width="30%"
      :before-close="closeDialog"
      size="mini"
    >
      <el-form
        ref="dictDataForm"
        :model="dictDataForm"
        label-width="80px"
        size="mini"
      >
        <el-form-item label="数据名称">
          <el-input v-model="dictDataForm.name"></el-input>
        </el-form-item>
        <el-form-item label="数据值">
          <el-input v-model="dictDataForm.value"></el-input>
        </el-form-item>
        <el-form-item label="排序值">
          <el-input-number
            size="mini"
            v-model="dictDataForm.sort"
            :max="99"
            :min="0"
          />
        </el-form-item>
        <el-form-item label="是否启用">
          <el-radio-group v-model="dictDataForm.enable">
            <el-radio
              v-for="item in enables"
              :key="item.name"
              :label="item.value"
              >{{ item.name }}</el-radio
            >
          </el-radio-group>
        </el-form-item>
        <el-form-item label="备注">
          <el-input type="textarea" v-model="dictDataForm.remark"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submit()" size="mini"
            >确定</el-button
          >
          <el-button @click="closeDialog()" size="mini">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    enables: {
      type: Array,
    },
    type: "",
    data: {
      type: Object,
    },
  },
  data() {
    return {
      isShowDialog: true,
      dictDataForm: {},
    };
  },
  created() {
    this.initdictDataForm();
    this.dictDataForm = this.data;
  },
  mounted() {},
  methods: {
    /**
     * 初始化字典数据
     */
    initdictDataForm() {
      this.dictDataForm = {
        name: "",
        typeId: this.type,
        enable: "1",
        value: "",
        sort: 0,
        remark: "",
      };
    },
    /**
     * 提交创建
     */
    submit() {
      this.$emit("submit", this.dictDataForm);
    },
    /**
     * 关闭创建对话框
     */
    closeDialog() {
      this.initdictDataForm();
      this.$emit("close");
    },
  },
};
</script>
<style scoped>
/* @import url(); 引入css类 */
</style>